home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MPW_TOOL / TOOLS / TOOLS_WI / ICON_8 / ICONX_FO / IDATA.C < prev    next >
Text File  |  1990-03-02  |  9KB  |  413 lines

  1. /*
  2.  * Various interpreter data tables.
  3.  */
  4.  
  5. #include "::h:config.h"
  6. #include "::h:rt.h"
  7. #include "rproto.h"
  8.  
  9. struct b_proc Bnoproc;
  10.  
  11. /*
  12.  * External declarations for function blocks.
  13.  */
  14.  
  15. char *fncnames[] = {
  16.  
  17. #ifdef PreProcess
  18. /* define(FncDef,"$1"`,') */
  19. /* define(FncDefV,"$1"`,') */
  20. /* include(../h/fdefs.h) /* */
  21. /* */
  22. /* undefine(`FncDef') */
  23. /* undefine(`FncDefV') */
  24. /* */
  25. #else                    /* PreProcess */
  26. #define FncDef(p,n) Lit(p),
  27. #define FncDefV(p) Lit(p),
  28. #include "::h:fdefs.h"
  29. #undef FncDef
  30. #undef FncDefV
  31. #endif                    /* PreProcess */
  32.    0
  33.    };
  34.  
  35. int fnsize = (sizeof(fncnames) / sizeof(char*)) - 1;
  36.  
  37. #ifdef PreProcess
  38. /* define(FncDef,extern struct b_proc B$1;) */
  39. /* define(FncDefV,extern struct b_proc B$1;) */
  40. /* include(../h/fdefs.h) /* */
  41. /* */
  42. /* undefine(`FncDef') */
  43. /* undefine(`FncDefV') */
  44. /* */
  45. #else                    /* PreProcess */
  46. #define FncDef(p,n) extern struct b_proc Cat(B,p);
  47. #define FncDefV(p) extern struct b_proc Cat(B,p);
  48. #include "::h:fdefs.h"
  49. #undef FncDef
  50. #undef FncDefV
  51. #endif                    /* PreProcess */
  52.  
  53. #ifdef PreProcess
  54. /* define(OpDef,extern struct b_proc B$1;) */
  55. /* include(../h/odefs.h) /* */
  56. /* undefine(`OpDef') */
  57. /* */
  58. #else                    /* PreProcess */
  59. #define OpDef(p,n,s) extern struct b_proc Cat(B,p);
  60. #include "::h:odefs.h"
  61. #undef OpDef
  62. #endif                    /* PreProcess */
  63.  
  64. extern struct b_proc Bbscan;
  65. extern struct b_proc Bcreate;
  66. extern struct b_proc Bescan;
  67. extern struct b_proc Bfield;
  68. extern struct b_proc Blimit;
  69. extern struct b_proc Bllist;
  70.  
  71. /*
  72.  * Array of addresses of function blocks.
  73.  */
  74. struct b_proc *functab[] = {
  75. #ifdef PreProcess
  76. /* define(FncDef,&B$1`,') */
  77. /* define(FncDefV,&B$1`,') */
  78. /* include(../h/fdefs.h) /* */
  79. /* undefine(`FncDef') */
  80. /* undefine(`FncDefV') */
  81. /* */
  82. #else                    /* PreProcess */
  83. #define FncDef(p,n) Cat(&B,p),
  84. #define FncDefV(p) Cat(&B,p),
  85. #include "::h:fdefs.h"
  86. #undef FncDef
  87. #undef FncDefV
  88. #endif                    /* PreProcess */
  89.    0
  90.    };
  91.  
  92. int ftsize = (sizeof(functab) / sizeof(struct b_proc *)) - 1;
  93.  
  94.  
  95. /*
  96.  * When an opcode n has a subroutine call associated with it, the
  97.  *  nth word here is the routine to call.
  98.  */
  99.  
  100. int (*optab[])() = {
  101.     err,
  102. #ifdef PreProcess
  103. /* define(OpDef,O$1`,') */
  104. /* include(../h/odefs.h) /* */
  105. /* undefine(`OpDef') */
  106. /* */
  107. #else                    /* PreProcess */
  108. #define OpDef(p,n,s) Cat(O,p),
  109. #include "::h:odefs.h"
  110. #undef OpDef
  111. #endif                    /* PreProcess */
  112.    Obscan,
  113.    err,
  114.    err,
  115.    err,
  116.    err,
  117.    err,
  118.    Ocreate,
  119.    err,
  120.    err,
  121.    err,
  122.    err,
  123.    Oescan,
  124.    err,
  125.    Ofield
  126.    };
  127.  
  128. #ifdef TraceBack
  129.  
  130. struct b_proc *opblks[] = {
  131.     NULL,
  132. #ifdef PreProcess
  133. /* define(OpDef,&B$1`,') */
  134. /* include(../h/odefs.h) /* */
  135. /* undefine(`OpDef') */
  136. /* */
  137. #else                    /* PreProcess */
  138. #define OpDef(p,n,s) Cat(&B,p),
  139. #include "::h:odefs.h"
  140. #undef OpDef
  141. #endif                    /* PreProcess */
  142.    &Bbscan,
  143.    NULL,
  144.    NULL,
  145.    NULL,
  146.    NULL,
  147.    NULL,
  148.    &Bcreate,
  149.    NULL,
  150.    NULL,
  151.    NULL,
  152.    NULL,
  153.    &Bescan,
  154.    NULL,
  155.    &Bfield,
  156.    NULL,
  157.    NULL,
  158.    NULL,
  159.    NULL,
  160.    NULL,
  161.    &Blimit,
  162.    &Bllist,
  163.    NULL,
  164.    NULL,
  165.    NULL
  166.    };
  167. #endif                    /* TraceBack */
  168.  
  169. #ifdef StrInvoke
  170. /*
  171.  * Array of names and corresponding functions.
  172.  */
  173.  
  174. struct pstrnm pntab[] = {
  175.  
  176. #ifndef BoundFunctions
  177. #ifdef PreProcess
  178. /* define(FncDef,"$1"`,' &B$1`,') */
  179. /* define(FncDefV,"$1"`,' &B$1`,') */
  180. /* include(../h/fdefs.h) /* */
  181. /* undefine(`FncDef') */
  182. /* undefine(`FncDefV') */
  183. /* */
  184. #else                    /* PreProcess */
  185. #define FncDef(p,n) Lit(p), Cat(&B,p),
  186. #define FncDefV(p) Lit(p), Cat(&B,p),
  187. #include "::h:fdefs.h"
  188. #undef FncDef
  189. #undef FncDefV
  190. #endif                    /* PreProcess */
  191. #endif                    /* BoundFunctions */
  192.  
  193. #ifdef PreProcess
  194. /* define(OpDef,$3`,' &B$1`,') */
  195. /* include(../h/odefs.h) /* */
  196. /* undefine(`OpDef') */
  197. /* */
  198. #else                    /* PreProcess */
  199. #define OpDef(p,n,s) s, Cat(&B,p),
  200. #include "::h:odefs.h"
  201. #undef OpDef
  202. #endif                    /* PreProcess */
  203.     0,         0
  204.     };
  205. #endif                    /* StrInvoke */
  206.  
  207. /*
  208.  * Structures for built-in values.  Parts of some of these structures are
  209.  *  initialized later. Since some C compilers cannot handle any partial
  210.  *  initializations, all parts are initialized later if any have to be.
  211.  */
  212.  
  213. /*
  214.  * Built-in csets
  215.  */
  216.  
  217. /*
  218.  * &ascii; 128 bits on, second 128 bits off.
  219.  */
  220. struct b_cset  k_ascii = {
  221.    T_Cset,
  222.    128,
  223.    cset_display(~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
  224.                  0,  0,  0,  0,  0,  0,  0,  0)
  225.    };
  226.  
  227. /*
  228.  * &cset; all 256 bits on.
  229.  */
  230. struct b_cset  k_cset = {
  231.    T_Cset,
  232.    256,
  233.    cset_display(~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
  234.         ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0)
  235.    };
  236.  
  237. /*
  238.  * &digits; bits corrosponding to 0-9 are on.
  239.  */
  240. struct b_cset  k_digits = {
  241.    T_Cset,
  242.    10,
  243. #if !EBCDIC
  244.    cset_display(0,  0,    0,  0x3ff, 0,  0, 0,  0,
  245.         0,  0,    0,  0,     0,  0,     0,  0)
  246. #else                    /* !EBCDIC */
  247.    cset_display(0,  0,    0,  0,    0,  0,    0,  0,
  248.         0,  0,    0,  0,  0,  0,  0,  0x3ff)
  249. #endif                    /* !EBCDIC */
  250.    };
  251.  
  252. /*
  253.  * Cset for &lcase; bits corresponding to lowercase letters are on.
  254.  */
  255. struct b_cset  k_lcase = {
  256.    T_Cset,
  257.    26,
  258. #if !EBCDIC
  259.    cset_display(0,  0,    0,  0,    0,  0,    ~01,  03777,
  260.         0,  0,    0,  0,    0,  0,    0,  0)
  261. #else                    /* !EBCDIC */
  262.    cset_display(0,  0,    0,  0,    0,  0,    0,  0,
  263.         0x3fe,    0x3fe,    0x3fc,    0,  0,    0,  0,    0)
  264. #endif                    /* !EBCDIC */
  265.    };
  266.  
  267. /*
  268.  * &ucase; bits corresponding to uppercase characters are on.
  269.  */
  270. struct b_cset  k_ucase = {
  271.    T_Cset,
  272.    26,
  273. #if !EBCDIC
  274.    cset_display(0,  0,    0,  0,    ~01,  03777, 0, 0,
  275.         0,  0,    0,  0,    0,  0,    0,  0)
  276. #else                    /* !EBCDIC */
  277.    cset_display(0,  0,    0,  0,    0,  0,    0,  0,
  278.         0,  0,    0,  0,    0x3fe,    0x3fe,    0x3fc,    0)
  279. #endif                    /* !EBCDIC */
  280.    };
  281.  
  282. /*
  283.  * &letters; bits corresponding to letters are on.
  284.  */
  285. struct b_cset  k_letters = {
  286.    T_Cset,
  287.    52,
  288. #if !EBCDIC
  289.    cset_display(0,  0,    0,  0,    ~01,  03777, ~01, 03777,
  290.         0,  0,    0,  0,    0,  0,    0,  0)
  291. #else                    /* !EBCDIC */
  292.    cset_display(0,  0,    0,  0,    0,  0,    0,  0,
  293.         0x3fe,  0x3fe,    0x3fc,  0, 0x3fe, 0x3fe, 0x3fc,    0)
  294. #endif                    /* !EBCDIC */
  295.    };
  296.  
  297. /*
  298.  * Built-in files.
  299.  */
  300.  
  301. struct b_file  k_errout = {T_File, NULL, Fs_Write};    /* &errout */
  302. struct b_file  k_input = {T_File, NULL, Fs_Read};    /* &input */
  303. struct b_file  k_output = {T_File, NULL, Fs_Write};    /* &outout */
  304.  
  305. /*
  306.  * Keyword trapped variables.
  307.  */
  308.  
  309.  
  310. struct b_tvkywd tvky_err = {T_Tvkywd, putint, {D_Integer}};    /* &error */
  311. struct b_tvkywd tvky_pos = {T_Tvkywd, putpos, {D_Integer}};    /* &pos */
  312. struct b_tvkywd tvky_ran = {T_Tvkywd, putint, {D_Integer}};    /* &random */
  313. struct b_tvkywd tvky_sub = {T_Tvkywd, putsub};             /* &subject */
  314. struct b_tvkywd tvky_trc = {T_Tvkywd, putint, {D_Integer}};    /* &trace */
  315.  
  316. /*
  317.  * Various constant descriptors.
  318.  */
  319.  
  320. struct descrip blank;             /* one-character blank string */
  321. struct descrip emptystr;         /* zero-length empty string */
  322. struct descrip errout = {D_File};    /* &errout */
  323. struct descrip input = {D_File};    /* &input */
  324. struct descrip lcase;            /* string of lowercase letters */
  325. struct descrip letr;            /* "r" */
  326. struct descrip nulldesc = {D_Null};    /* null value */
  327. struct descrip onedesc = {D_Integer};    /* integer 1 */
  328. struct descrip ucase;            /* string of uppercase letters */
  329. struct descrip zerodesc = {D_Integer};    /* integer 0 */
  330.  
  331. /*
  332.  * The tended descriptors.
  333.  */
  334.  
  335. struct descrip tended[6];
  336.  
  337. /*
  338.  * Run-time error numbers and text.
  339.  */
  340. struct errtab errtab[] = {
  341.    101, "integer expected",
  342.    102, "numeric expected",
  343.    103, "string expected",
  344.    104, "cset expected",
  345.    105, "file expected",
  346.    106, "procedure or integer expected",
  347.    107, "record expected",
  348.    108, "list expected",
  349.    109, "string or file expected",
  350.    110, "string or list expected",
  351.    111, "variable expected",
  352.    112, "invalid type to size operation",
  353.    113, "invalid type to random operation",
  354.    114, "invalid type to subscript operation",
  355.    115, "list, set, or table expected",
  356.    116, "invalid type to element generator",
  357.    117, "missing main procedure",
  358.    118, "co-expression expected",
  359.    119, "set expected",
  360.    120, "cset or set expected",
  361.    121, "function not supported",
  362.    122, "set or table expected",
  363.    123, "invalid type",
  364.    124, "table expected",
  365.  
  366.    201, "division by zero",
  367.    202, "remaindering by zero",
  368.    203, "integer overflow",
  369.    204, "real overflow, underflow, or division by zero",
  370.    205, "value out of range",
  371.    206, "negative first argument to real exponentiation",
  372.    207, "invalid field name",
  373.    208, "second and third arguments to map of unequal length",
  374.    209, "invalid second argument to open",
  375.    210, "non-ascending arguments to detab/entab",
  376.    211, "by value equal to zero",
  377.    212, "attempt to read file not open for reading",
  378.    213, "attempt to write file not open for writing",
  379.    214, "input/output error",
  380.    215, "attempt to refresh &main",
  381.    216, "external function not found",
  382.  
  383.  
  384.    301, "evaluation stack overflow",
  385.    302, "system stack overflow",
  386.    303, "inadequate space for evaluation stack",
  387.  
  388. #ifdef FixedRegions
  389.    304, "inadequate space in qualifier list",
  390. #endif                    /* FixedRegions */
  391.  
  392.    305, "inadequate space for static allocation",
  393.    306, "inadequate space in string region",
  394.    307, "inadequate space in block region",
  395.    308, "system stack overflow in co-expression",
  396.  
  397. #if VMS
  398.    351, "insufficient MAXMEM limit",
  399. #endif                    /* VMS */
  400.  
  401. #ifndef Coexpr
  402.    401, "co-expressions not implemented",
  403. #endif                    /* Coexpr */
  404.  
  405.    500, "program malfunction",        /* for use by runerr() */
  406.  
  407. /*
  408.  * End of operating-system specific code.
  409.  */
  410.  
  411.    0,    ""
  412.    };
  413.